<template>
  <div class="contents">
    <PanelTitle title="水肥建议" />

    <div ref="maps" class="maps mt"></div>
  </div>
</template>

<script setup>
import { ref, onMounted } from "vue";
import echarts from "@/components/echarts";
import PanelTitle from "../../component/PanelTitle.vue";
import http from "@/api/http";
import { env } from "@/utils/env";
import { fitChartSize } from "@/utils/dataUtil.js";

const maps = ref(null);
onMounted(() => {
  var myChart = echarts.init(maps.value);
  myChart.setOption({
    grid: {
      left: "3%",
      right: "4%",
      bottom: "8%",
      top: "18%",
      containLabel: true,
    },
    tooltip: {
      show: true,
      trigger: "axis",
    },
    xAxis: [
      {
        type: "category",
        data: [
          "1月",
          "2月",
          "3月",
          "4月",
          "5月",
          "6月",
          "7月",
          "8月",
          "9月",
          "10月",
          "11月",
          "12月",
        ],
        axisLabel: {
          textStyle: {
            color: "#7AFFFD",
            fontSize: fitChartSize(9),
          },
        },
        axisPointer: {
          type: "shadow",
        },
        axisTick: {
          show: false,
        },
        axisLine: {
          show: false,
        },
      },
    ],
    yAxis: [
      {
        // name: "单位：人",
        // nameTextStyle: {
        //   color: "#fff",
        //   fontSize: fitChartSize(9),
        //   padding: [0, fitChartSize(-600), fitChartSize(4), 0],
        // },
        type: "value",
        splitNumber: 4,
        splitLine: {
          lineStyle: {
            color: "rgba(255,255,255,0.09)", //线条颜色
            type: "dashed", //线条样式，默认是实现，dashed是虚线
          },
        },
        min: 0,
        axisLabel: {
          textStyle: {
            color: "#7AFFFD",
            fontSize: fitChartSize(9),
          },
        },
        axisTick: {
          show: true,
          lineStyle: {
            color: "rgba(255,255,255,0.09)", //线条颜色
            type: "dashed", //线条样式，默认是实现，dashed是虚线
          },
        },
        axisLine: {
          show: true,
          lineStyle: {
            color: "rgba(255,255,255,0.09)", //线条颜色
            type: "dashed", //线条样式，默认是实现，dashed是虚线
          },
        },
      },
    ],
    series: [
      {
        type: "bar",
        barWidth: fitChartSize(12),
        itemStyle: {
          normal: {
            color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
              {
                offset: 0,
                color: "rgba(0, 249, 176, 1)",
              },
              {
                offset: 1,
                color: "rgba(19, 37, 67, 0.08)",
              },
            ]),
          },
        },
        data: [200, 150, 100, 200, 150, 100, 200, 150, 100, 200, 150, 100],
        // showBackground: true,
        // backgroundStyle: {
        //   color: "rgba(255, 255, 255, .2)",
        // },
      },
    ],
  });
});
</script>

<style scoped lang="scss">
.contents {
  background: linear-gradient(
    to bottom,
    rgba(5, 79, 99),
    rgba(5, 79, 99, 0.1),
    rgba(5, 79, 99)
  );
  border-radius: vh(8);
  border: vh(1) solid rgba(6, 112, 180, 1);
  .mt {
    margin-top: vh(-40);
  }
}

.maps {
  height: vh(300);
  width: 100%;
}
</style>